package com.yiqi.zhiyuan.feature.mine.presenter;

import com.yiqi.zhiyuan.entity.vo.DiverCenterVO;
import com.yiqi.zhiyuan.feature.mine.contract.MineContract;
import com.yiqi.zhiyuan.feature.mine.dependencies.mine.DaggerMinePresenterComponent;

import javax.inject.Inject;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * @ProjectName: ZhiYuan
 * @Description: java类作用描述
 * @Author: lijuwen
 * @CreateDate: 2019/3/14 10:54
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/3/14 10:54
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class MinePresenter implements MineContract.Presenter {

    private MineContract.View mView;

    @Inject
    MineContract.Model mModel;



    public MinePresenter(MineContract.View mView) {
        this.mView = mView;
        DaggerMinePresenterComponent.create().inject(this);
    }




    @Override
    public void doGetDiverCenter() {
        mModel.doGetDiverCenter()
                .compose(mView.<DiverCenterVO>bindToLife())
                .subscribe(new Observer<DiverCenterVO>() {
                    @Override
                    public void onSubscribe(Disposable d) {
                    }

                    @Override
                    public void onNext(DiverCenterVO diverCenterVO) {
                        mView.showDiverCenterSuccess(diverCenterVO);
                    }

                    @Override
                    public void onError(Throwable e) {
                        mView.showDiverCenterError(e.getMessage());
                    }

                    @Override

                    public void onComplete() {

                    }
                });
    }

    @Override
    public void start() {

    }
}
